<template>
	<view>
		<view class="rows " >
			<view class="navBar" :style="{backgroundColor:bgColor,color:color}">
				<view class="rows" :style="{height:`${System.statusBarHeight}px`}"></view>
				<view class="row a-center" :style="{height:`${navHeight}px`,width:`${navWidth}px`}">
					<view class="left" @click="backBtn" v-if="!isTabbar && !searchShow">
						<view class="iconfont icon-shouye2 size36 p-left24"
						    :class="isBack?'icon-xiangzuo':'icon-shouye-zhihui'"></view>
					</view>
					<view class="flex-1 title ellipsis p-left24" :class="{'m-left90': searchShow}">{{title}}</view>
				</view>
			</view>
		</view>
		<view class="rows" :style="{height:System.statusBarHeight+navHeight+'px'}" v-if="transparent"></view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		name: "navBar",
		props:{
			title:{
				type:String,
				default:'',
			},
			transparent:{
				type: Boolean,
				default: true
			},
			color:{
				type:String,
				default:'#000000'
			},
			bgColor:{
				type:String,
				default:'#ffffff'
			},
			isBack:{
				type: Boolean,
				default: true
			},
			isTabbar:{
				type: Boolean,
				default: false
			},
			searchShow:{
				type: Boolean,
				default: false
			}
		},
		
		data() {
			return {
				capsuleWidth: getApp().globalData.capsuleWidth,
			};
		},
		methods:{
			backBtn(){
				if(this.isTabbar) return
				if(this.isBack) return this.back()
				this.backHome()
			}
		},
		computed: {
			...mapState(['System', 'navHeight', 'navWidth']),
		},
		
	}
</script>

<style lang="scss" scoped>
	.navBar {
		width:100%;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 1000;
	}

	.left {
		height: 100%;
		display: flex;
		align-items: center;
	}

	.title {
		line-height: 40px;
		font-size: 32rpx;
		font-weight: bold;
	}
</style>